import { createElement, HTMLAttributes, type FC } from 'react';
import classNames from 'classnames';

import { feedLikeDefaultProps } from './defaultProps';
import type { FeedLikeOptions } from './type';

export interface FeedLikeProps extends FeedLikeOptions, HTMLAttributes<HTMLElement> {}

const FeedLike: FC<FeedLikeProps> = (props) => {
  const { className, as, children, forwardedRef, ...feedLikeProps } = props;

  return createElement(
    as!,
    { ref: forwardedRef, className: classNames('like', className), ...feedLikeProps },
    children,
  );
};

FeedLike.displayName = 'FeedLike';
FeedLike.defaultProps = feedLikeDefaultProps;

export default FeedLike;
